<?php 
$infoError = array();

if($user->isLogged()) {
	if(isset($_REQUEST['updateinfo'])) {
		
		if($_POST['alias']!="Non specificato" && $_POST['alias']!="") {
			$profile->alias = htmlentities($_POST['alias']);
		}
		if($_POST['description']!=""){
			$profile->description = htmlentities($_POST['description']);
		}
		
	}

}

if(isset($_REQUEST['updateinfo']) && count($infoError)==0) {
	$resultUpgrade = $profile->updateInfo($user->id);
	$changeInfoSuccess = null;
	
	if($resultUpgrade){
		$changeInfoSuccess = "<p> Informazioni cambiate con successo </p>";
	}		
}
	
?>
<h3 style="width:69%">Modifica informazioni</h3>
	<form action="#" method="POST">
		<table>
			<tr>
				<td>Alias: </td>
				<td><input type="text" value="<?php echo $profile->getTrimField("alias");?>" name="alias"/></td>
			</tr>
			<tr>
				<td>Description: </td>
				<td><input type="text" value="<?php echo $profile->getTrimField("description");?>" name="description"/></td>
			</tr>
			<tr>
				<td></td>
				<td><input type="submit" id="updateinfo" value="Modifica" name="updateinfo"/></td>
			</tr>
		</table>
	</form>
	
<?php 
	if(isset($changeInfoSuccess)){
		echo '<div id="successChangeInfo">';
			echo $changeInfoSuccess;
			
		echo '</div>';
		
		?>
			<body onLoad="setInfo('<?php echo $_POST['alias'];?>' , '<?php echo $_POST['description']; ?>');"></body>
		<?php 
	}
	
?>